<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>社区页</title>

		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<!-- 引入css文件 -->
		<link rel="stylesheet" href=" ../css/sm.min.css">
		<link rel="stylesheet" href=" ../css/sm-extend.min.css">
		<link rel="stylesheet" href=" ../css/iconfont.css">

		<script src='../js/vue.js'></script>
		<script src='../js/axios.min.js'></script>
		<style type="text/css">
			/* 卡片内容加边距 */
			.my-cont {
				padding: .2rem .75rem;
			}

			/* 单张照片 */
			.my-cont .c1 img {
				width: 60%;
				margin: 0.5rem 0;
			}
			
			/* 两张照片 */
			.my-cont .c2 img {
				width: 40%;
				margin: 0.5rem 5%;
			}
			
			/* 三张照片及以上 */
			.my-cont .c3 img {
				width: 32%;
				margin: 0.5rem 0;
			}
			/* 用户动态信息上限 */
			.userMes{
				max-height: 3rem;
				overflow: hidden;
				font-size: 0.7rem;
			}
			/* 背景色白色 */
			.page,
			.page-group {
				background-color: white;
			}


			/* 去掉卡片边距 */
			.card {
				margin: 0;
			}

			.page {
				/* margin: 0.2rem; */
			}
			.list-block{
				margin-top: 0rem;
			}
			.card-content{
				padding-top: 0.5rem;
			}
			/* 用户字体 */
			.list-block .my-user {
				font-size: 0.6rem;
				color: rgb(150, 150, 150);
			}

			.list-block .media-list .item-title{
				font-size: 0.7rem;
				font-weight: 700;
			}
			/* 头像圆角 */
			.my-photo img {
				border-radius: 1rem;
			}


			/* 顶部搜索栏左间距 */
			.my-top {
				/* margin-left: 0.4rem; */
			}

			/* 卡片主内容左右边距 */
			.my-data {
				position: static;
				border-bottom: 1px solid rgb(220, 220, 220);
				padding-right: 60%;
				padding-left: 1rem;
				padding-bottom: 1rem;
			}

			/* 顶部社区样式 */
			/* 最外层 */
			.content {
				/* background-color: #3d005f; */
			}

			.content .native-scroll {
				background-color: white;
			}

			.my-top {
				/* height: 10rem; */
				background-color: #1f0034;
				padding: 1rem 0.5rem;
				padding-top: 0.3rem;
			}

			/* 搜索顶部工具栏 */
			#my-top-find {
				height: 1.5rem;
			}

			#my-top-find>div {
				float: right;
				height: 100%;
				text-align: center;
				line-height: 1.5rem;
			}

			/* 搜索图标左右边距 */
			#find {
				margin: 0 0.5rem;
			}

			#return span {
				color: white;
			}

			/* 返回 */
			#my-top-find #return {
				position: absolute;
				height: 1.5rem;
			}

			/* 搜索 */
			#find span {
				font-size: 1rem;
				color: white;
			}

			/* 管理 */
			#manage span {
				font-size: 1.2rem;
				color: white;
			}

			/* 头像和简介外框 */
			#my-top-forum {
				margin-top: 0.3rem;
				height: 3rem;
			}

			#my-top-forum>div {
				float: left;
				height: 100%;
				color: white;
			}

			/* 社区头像 */
			#my-top-img {
				width: 3rem;
				height: 100%;
				border-radius: 1rem;
				overflow: hidden;
				margin-right: 1rem;
			}

			/* 社区头像内图片 */
			#my-top-img img {
				width: 100%;
				height: 100%;
			}

			/* 用户头像 */
			.user-photo img {
				/* width: 2rem;
				height: 2rem; */
				border-radius: 1rem;
			}

			/*  */
			#forumIntr {
				width: 70%;
			}

			/* 社区信息 */
			#my-top-name {
				width: 13rem;
				height: 1.2rem;
				line-height: 1.2rem;
				font-size: 0.7rem;
				font-weight: 700;
			}

			#my-top-lv {
				height: 0.8rem;
				font-size: 0.5rem;
			}

			#userExp {
				font-size: 1.3rem;
				line-height: 0.8rem;
			}

			#my-top-intro {
				height: 0.9rem;
				font-size: 0.5rem;
			}

			/* 关注 */
			.concern {
				float: right;
				width: 3rem;
				height: 1rem;
				line-height: 1rem;
				font-size: 0.5rem;
				text-align: center;
				color: #0086bf;
				background-color: #befcff;
				border-radius: 0.4rem;

			}

			/* 添加话题入口 */
			#addTopic {
				position: fixed;
				bottom: 2rem;
				right: 1rem;
			}

			#addTopic span {
				font-size: 1.5rem;
			}

			/* popup遮罩异常 */
			.modal-overlay.modal-overlay-visible,
			.popup-overlay.modal-overlay-visible,
			.preloader-indicator-overlay.modal-overlay-visible {
				visibility: hidden;
			}

			/* 发送动态弹窗 */
			.popup-addTopic .content-block {
				margin-top: 0.2rem;
			}

			/* 顶部高度 */
			.addTopic-top>div {
				height: 2rem;
				line-height: 2rem;
				font-size: 0.8rem;
				text-align: center;
				color: #000000;
			}

			.addTopic-top .t1 {
				text-align: left;
			}
			.addTopic-top .t2 {
				font-size: 0.7rem;
			}

			.addTopic-top .t3 {
				text-align: right;
				color: rgb(0, 149, 255);
			}

			/* 文本顶部高度 */
			#addTopic-count {
				margin-top: 0rem;
			}

			/* 文本域 */
			#addTopic-count textarea {
				height: 6rem;
			}

			/* 图片 */
			.userImg {
				position: relative;
			}

			.userImg img {
				width: 100%;
				height: 100%;
			}

			.imgDel {
				position: absolute;
				top: 0.2rem;
				right: 0.32rem;
				font-size: 0.8rem;
			}

			/* 图片添加 */
			#addImg {
				position: absolute;
				opacity: 0;
				width: 100%;
				height: 100%;
			}
			a{
				color: inherit;
			}
			a:active{
				color: inherit;
			}
			/* 赞，回复数字 */
			.numType{
				font-size: 0.7rem;
				padding-right: 0.2rem;
				position: relative;
				top: 0.1rem;
			}
		</style>
		<style type="text/css">
			.infinite-scroll-preloader {
				margin-top: -20px;
			}
		</style>
	</head>
	<body>
		<!-- page 容器 -->
		<div class="page">
			<!-- 这里是页面内容区 -->
			<div class="content">
				<!-- 顶部区域 -->
				<div class="my-top">
					<!-- <div class="search-input col-80">
							<input type="search" id='search' placeholder='输入关键字...' />
						</div> -->
					<!-- 顶部搜索栏 -->
					<div id="my-top-find">
						<div @click="returns" id="return">
							<a href="#">
								<span class="iconfont icon-fanhui"></span>
							</a>
						</div>
						<div id="find">
							<a href="#" data-popup=".popup-find" class="open-popup">
								<span class="iconfont icon-sousuo"></span>
							</a>
						</div>
						<div v-if="forumForum!=null&&forumForum.admin==1" id="manage">
							<a :href="admin()">
								<span class="iconfont icon-banzhengfuwu"></span>
							</a>
						</div>
					</div>
					<!-- 社区展示 -->
					<div id="my-top-forum">
						<!-- 头像 -->
						<div id="my-top-img" v-if="forumForum!=null">
							<a :href="details()">
								<img :src="imgSrc(forumForum.forum.photo)">
							</a>
						</div>
						<!-- 介绍 -->
						<div id="forumIntr">
							<div id="my-top-name" v-if="forumForum!=null">
								{{forumForum.forum.name}}
							</div>
							<div id="my-top-lv">
								<!-- 判断是否关注，进而显示经验等级 -->
								<span id="userExp" v-if="concernStatus==0" :class="ico(exp)"></span>
								<span v-if="concernStatus==1">
									<span>用户：{{concernNum}}</span>&nbsp&nbsp&nbsp
									<span>话题：{{topicsNum}}</span>
								</span>
								<div class="concern" @click="alterConcern">
									{{concernText}}
								</div>
							</div>
							<div id="my-top-intro">
								<span class="iconfont icon-flag"></span>
								<span v-if="forumForum!=null">{{forumForum.forum.intro}}</span>
							</div>
						</div>
					</div>

				</div>
				<!-- 标题栏 -->
				<div class="buttons-tab fixed-tab" data-offset="0">
					<a id="new" class="tab-link active button">最新</a>
					<a id="hot" class="button">最热</a>
					<a id="collect" class="button">最多收藏</a>
				</div>
				<!-- 主内容 -->
				<div class="active infinite-scroll" data-distance="50">
					<div class="list-block">
						<div class="card list-container ">

							<!-- 社区 -->
							<!-- <div class="card-content">
								<div class="list-block media-list">
									<ul>
										<li class="item-content">
											<div class="item-media my-photo">
												<img src="http://gqianniu.alicdn.com/bao/uploaded/i4//tfscom/i3/TB10LfcHFXXXXXKXpXXXXXXXXXX_!!0-item_pic.jpg_250x250q60.jpg"
												 width="35">
											</div>
											<div class="item-inner">
												<div class="item-title-row">
													<div class="item-title">张三</div>
												</div>
												<div class="item-subtitle my-user">
													12：50
												</div>
											</div>
										</li>
									</ul>
								</div>
							</div>
							!-- 内容 --
							<div class="my-cont">
								<span>
									安达市大所大所多安达市大所大所多安达市安达市大所大所多安达市大所大所多安达市大所大所多安达市大所大所多<br>
								</span>
								<span class="c1">
									<img src="http://localhost:12317/img/joylife/10.jpg">
								</span>
							</div>
							<div class="card-footer my-data">
								<span>5
									<span class="icon iconfont icon-appreciate"></span>
								</span>
								<span>5
									<span class="icon iconfont icon-message"></span>
								</span>
								<span>
									<span class="icon iconfont icon-forward"></span>
								</span>
							</div> -->

						</div>
					</div>
					<!-- 加载提示符 -->
					<div class="infinite-scroll-preloader">
						<div class="preloader"></div>
					</div>
				</div>
			</div>
			<div id="addTopic" class="open-popup" data-popup=".popup-addTopic">
				<span class="iconfont icon-jia"></span>
			</div>
			<!-- About Popup -->
			<!-- 搜索弹窗 -->
			<div class="popup popup-find">
				<div class="content-block">
					<div class="searchbar row">
						<div class="search-input col-85">
							<input type="search" id='search' placeholder='输入关键字...' />
						</div>
						<a id="findTx" class="close-popup button button-fill button-primary col-15"><span class="icon icon-search"></span></a>
					</div>

					<p><a href="#" class="close-popup button button-fill button-primary col-15" style="width: 3rem;">返回</a></p>
				</div>
			</div>
			<!-- 发布消息 -->
			<div class="popup popup-addTopic">
				<div class="content-block">
					<!-- 工具栏 -->
					<div class="addTopic-top row">
						<div class="t1 col-33">
							<span class="close-popup iconfont icon-fanhui"></span>
						</div>
						<div class="t2 col-33" v-if="forumForum!=null">
							<span>发送到{{forumForum.forum.name}}</span>
						</div>
						<div @click="addTopic" class="t3 col-33">
							<span>发布</span>
						</div>
					</div>
					<!-- 输入区域 -->
					<div id="addTopic-count" class="item-content list-block">
						<textarea id="topicContent" name="topicContent" maxlength="10000" required placeholder="尽情发挥吧..."></textarea>
					</div>
					<!-- 图片 -->
					<div id="addTopic-img" class="row">
						<div v-for="(item,index) in imgs" class="userImg col-33">
							<span @click="delImg(index)" class="imgDel iconfont icon-shanchu"></span>
							<img :src="imgSrc(item)">
						</div>
						<div v-if="imgs.length<3" class="userImg col-33">
							<!--  -->
							<form id="imgForm" method="post" enctype="multipart/form-data">
								<input type="file" @change="addImgMethod" id="addImg" name="img" accept="image/jpeg" />
							</form>
							<img src="../img/iconfont-tianjia.png">
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src='../js/jquery-3.2.1.min.js'></script>
		<script src='../js/sm.js'></script>
		<script src='../js/sm-extend.js'></script>
		<script src="../js/config.js"></script>

		<script>
			/* 获取请求参数 */
			function getUrlParam(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
				var r = window.location.search.substr(1).match(reg); //匹配目标参数
				if (r != null) return unescape(r[2]);
				return null; //返回参数值
			}
			var forumId = getUrlParam('forumId');
			//绑定vue
			var app = new Vue({
				el: ".page",
				data: {
					forumForum: null,
					concernText: "",
					concernStatus: 0,
					exp: 0,
					concernNum: 0,
					topicsNum: 0,
					imgs: [],
					addImgVal: ""
				},
				created() {
					axios.get(serviceIP+"/forum/comIntroduce?forumId=" + forumId,{headers:{"token":token,"refreshtoken":refreshtoken}}).then(result => {
						this.forumForum = result.data.data;
						if (result.data.data.status == 0) {
							//尚未关注
							this.concernText = "关注";
							this.concernStatus = 1;
							this.concernNum = result.data.data.concernNum;
							this.topicsNum = result.data.data.topicsNum;
						} else {
							this.concernText = "取消关注";
							this.concernStatus = 0;
							this.exp = result.data.data.exp;
						}
					});
				},
				methods: {
					/* 头像 */
					imgSrc: function(src) {
						return  src;
					},
					/* 详情跳转页面 */
					details:function(){
						return "forum-forum-details.html?forumId="+forumId;
					},
					/* 管理跳转页面 */
					admin:function(){
						return "forum-admin.html?forumId="+forumId;
					},
					/* 添加照片 */
					addImgMethod: function() {
						var path=$("#addImg").val();
						if(path!=null&&path!=""){
							var that = this;
							$.ajax({
								url: serviceIP+"/forum/addImg",
								type: "post",
								dataType: "json",
								cache: false,
								data: new FormData($("#imgForm")[0]),
								headers: {
											"token":token,
											"refreshtoken":refreshtoken
										},
								processData: false, // 不处理数据
								contentType: false, // 不设置内容类型
								success: function(data) {
									that.imgs.unshift(data.url);
								}
							});
						}
					},
					/* 发送话题 */
					addTopic: function() {
						var text = $("#topicContent").val();
						if (text.length < 5) {
							$.toast("内容太短了！");
						} else {
							var userImgs = this.imgs;
							var that = this;
							$.ajax({
								type: 'get',
								url: serviceIP+"/forum/addTopic",
								dataType: 'json',
									data:{
										content: text,
										imgs: userImgs,
										forumId: forumId
									},
								headers: {
										"token":token,
										"refreshtoken":refreshtoken
									},
								success:function (data) {
									if (data != 0) {
										if(data == 1){
											$.toast("已发布，经验+15");
										}else{
											$.toast("已发布");
										}
										$("#topicContent").val("");
										that.imgs = [];
										//重新加载
										site = 1;
										find = "";
										lastIndex = 1;
										$('.infinite-scroll .list-container').html("");
										$("#new").attr("class", "tab-link active button");
										$("#hot").attr("class", "button");
										$("#collect").attr("class", "button");
										$.attachInfiniteScroll($('.infinite-scroll'));
										aja();
										//关闭弹窗
										$.closeModal('.popup-addTopic');
									} else {
										$.toast("失败，系统维护中");
									}
								}});
						}
					},
					/* 经验对应图标等级判断 */
					ico: function(exp) {
						if (exp <= 15) {
							return "iconfont icon-icon-test4";
						} else if (exp <= 50) {
							return "iconfont icon-icon-test2";
						} else if (exp <= 100) {
							return "iconfont icon-icon-test3";
						} else if (exp <= 300) {
							return "iconfont icon-icon-test5";
						} else if (exp <= 600) {
							return "iconfont icon-icon-test8";
						} else if (exp <= 1200) {
							return "iconfont icon-icon-test9";
						} else if (exp <= 2500) {
							return "iconfont icon-icon-test6";
						} else if (exp <= 5000) {
							return "iconfont icon-icon-test10";
						} else {
							return "iconfont icon-icon-test7";
						}
					},
					alterConcern: function() {
						if (this.concernStatus == 1) {
							//添加关注
							axios.get(serviceIP+"/forum/concernsDetail", {
								params: {
									forumId: forumId,
									status: 1
								},
								headers:{"token":token,"refreshtoken":refreshtoken}
							}).then(result => {
								if (result.data.status == 1) {
									$.toast("关注成功");
									this.concernText = "取消关注";
									this.concernStatus = 0;
									this.exp = result.data.exp;
								} else {
									$.toast("失败，系统维护中");
								}
							});
						} else {
							//取消关注
							axios.get(serviceIP+"/forum/concernsDetail", {
								params: {
									forumId: forumId,
									status: 0
								},
								headers:{"token":token,"refreshtoken":refreshtoken}
							}).then(result => {
								if (result.data.status == 0) {
									$.toast("已取消");
									this.concernText = "关注";
									this.concernStatus = 1;
									this.concernNum = result.data.concernNum;
									this.topicsNum = result.data.topicsNum;
								} else {
									$.toast("失败，系统维护中");
								}
							});
						}
					},
					//返回
					returns: function() {
						window.history.go(-1);
						//location.href = "forum-index.html";
					},
					//图片删除
					delImg: function(index) {
						this.imgs.splice(index, 1);
					}
				},
				//监听
				watch: {


				}
			});
		</script>
		<script type="text/javascript">
			//所有图片数据
			var allPhoto={};
			//当下图片浏览器数据
			var newphotos=new Array();
			$(function(){
			   $(document).on('click','.pb-popup',function () {
				 var myPhotoBrowserPopup = $.photoBrowser({
					   photos :newphotos,
					   type: 'popup'
				});
				myPhotoBrowserPopup.open();
			   });
			})
			/* 切换照片数组 */
			function changePhoto(id){
				newphotos=allPhoto[id];
				//console.log(newphotos);
			}
		</script>
		<script type="text/javascript">
			//话题赞状态更改
			function alterPraise(that,topicId) {
				$.ajax({
					type: 'get',
					url: serviceIP+"/forum/alterTopicPraise",
					dataType: 'json',
						data:{
							topicId: topicId
						},
					headers: {
							"token":token,
							"refreshtoken":refreshtoken
						},
					success:function (data) {
						if(data.status==1){
							$(that).prev().html($(that).prev().html() * 1 + 1 * 1);
							$(that).attr("class", "icon iconfont icon-appreciate_fill_light");
							$.toast("已赞！");
						}else if(data.status==0){
							$(that).prev().html($(that).prev().html() * 1 - 1 * 1);
							$(that).attr("class", "icon iconfont icon-appreciate");
							$.toast("取消赞！");
						}
					}});
			}
		</script>
		<script>
			// 加载flag
			var loading = false;
			// 最多可加载的条目
			var maxItems = 100;
			// 每次加载添加多少条目
			var itemsPerLoad = 5;
			// 初始页
			var lastIndex = 1;
			//查找
			var find = "";
			//当前位置
			var site = 1;
			// 生成新条目的HTML
			function addItems(topic) {
				var html = '<div class="card-content">' +
					'<div class="list-block media-list">' +
					'<ul>' +
					'<li class="item-content">' +
					'<div class="item-media user-photo">' +
					'<a href="forum-other-centre.html?userId='+topic.centerUser.id+'"><img src="' + topic.centerUser.photo + '" width="35" height="35">' +
					'</a></div>' +
					'<div class="item-inner">' +
					'<div class="item-title-row">' +
					'<div class="item-title">' + topic.centerUser.nickname + '</div>' +
					'</div>' +
					'<div class="item-subtitle my-user">';

				// 判断日期时间
				var num = new Date().getTime() - Date.parse(topic.forumTopic.date);
				var date = new Date(Date.parse(topic.forumTopic.date));
				//一小时以内
				if (num < 3600000) {
					html += '<span>' + Math.ceil(num / 60000) + '分钟前</span>';
				} else if (date.setHours(0, 0, 0, 0) == new Date().setHours(0, 0, 0, 0)) {
					//今天发送的
					html += '<span>' + topic.forumTopic.date.substring(11, 16) + '</span>';
				} else {
					//之前的信息
					html += '<span>' + topic.forumTopic.date.substring(0, 10) + '</span>';
				}

				html += '</div>' +
					'</div>' +
					'</li>' +
					'</ul>' +
					'</div>' +
					'</div>' +
					'<div class="my-cont">' +
					'<a href="forum-Topic.html?topicId='+topic.forumTopic.id+'"><div class="userMes"><span>' + topic.forumTopic.content + '</div></a>' +
					'</span>';
				// 判断照片数量
				if (topic.forumPhotos.length == 1) {
					html +='<span class="c1">' +
						'<img class=" pb-popup" onclick="changePhoto(\''+topic.forumTopic.id+'\')" src="'+ topic.forumPhotos[0].photo + '">' +
						'</span>';
				} else if (topic.forumPhotos.length == 2) {
					html += '<span class="c2">' +
						'<img class=" pb-popup" onclick="changePhoto(\''+topic.forumTopic.id+'\')"  src="'+ topic.forumPhotos[0].photo + '">' +
						'<img class=" pb-popup" onclick="changePhoto(\''+topic.forumTopic.id+'\')"  src="'+ topic.forumPhotos[1].photo + '">' +
						'</span>';
				} else if (topic.forumPhotos.length == 3) {
					html += '<span class="c3">' +
						'<img class=" pb-popup" onclick="changePhoto(\''+topic.forumTopic.id+'\')"  src="'+ topic.forumPhotos[0].photo + '">' +
						'<img class=" pb-popup" onclick="changePhoto(\''+topic.forumTopic.id+'\')"  src="'+ topic.forumPhotos[1].photo + '">' +
						'<img class=" pb-popup" onclick="changePhoto(\''+topic.forumTopic.id+'\')"  src="'+ topic.forumPhotos[2].photo + '">' +
						'</span>';
				}
				//保存图片
				if(topic.forumPhotos!=null&&topic.forumPhotos.length!=0){
					var tempPhoto=new Array();
					$.each(topic.forumPhotos, function(i, item) {
						tempPhoto.push(item.photo);
					}); 
					//保存
					allPhoto[topic.forumTopic.id]=tempPhoto;
				}
				
				html += '</div>' +
					'<div class="card-footer my-data">' +
					'<span><span class="numType">' + topic.topicPraiseNum +
					'</span><span onclick="alterPraise(this,\'' + topic.forumTopic.id +
					'\')"  class="';
				/* 判断是否点赞 */
					if(topic.praiseStatus==1){
						html +='icon iconfont icon-appreciate_fill_light"></span>';
					}else{
						html +='icon iconfont icon-appreciate"></span>';
					}
					html +='</span>' +
					'<span><span class="numType">' + topic.replyNum +
					'</span><a href="forum-Topic.html?topicId='+topic.forumTopic.id+'"><span class="icon iconfont icon-message"></span>' +
					'</a></span>' +
					'<span>' +
					/* '<span class="icon iconfont icon-forward"></span>' + */
					'</span>' +
					'</div>';

				// 添加新条目
				$('.infinite-scroll .list-container').append(html);
			}
			//异步请求封装
			function aja() {
				// 如果正在加载，则退出
				if (loading) return;
				// 设置flag
				loading = true;
				//判断url地址
				var url;
				if (find == "") {
					url = serviceIP+"/forum/comNewMes";
				} else {
					url = serviceIP+"/forum/search";
				}
				//请求加载信息
				$.ajax({
					type: 'get',
					url: serviceIP+"/forum/comNewMes",
					dataType: 'json',
						data:{
							page: lastIndex,
							limit: itemsPerLoad,
							forumId: forumId,
							find: find,
							site: site
						},
					headers: {
							"token":token,
							"refreshtoken":refreshtoken
						},
					success:function (data) {
						// 重置加载flag
						loading = false;
						//页面遍历添加
						$.each(data.data.list, function(i, item) {
							addItems(item);
						});
						// 更新最后加载的序号
						lastIndex++;
						//无数据
						if (data.data.size < itemsPerLoad) {
							// 删除加载提示符
							$('.infinite-scroll-preloader').remove();
						}
						if (data.data.size < 1) {
							// 加载完毕，则注销无限加载事件，以防不必要的加载
							$.detachInfiniteScroll($('.infinite-scroll'));
							// 删除加载提示符
							$('.infinite-scroll-preloader').remove();
							//提醒
							$.toast("没更多消息了，看看别的吧！");
							return;
						}
						//容器发生改变,如果是js滚动，需要刷新滚动
						$.refreshScroller();
					}
				});
			}
			// 注册'infinite'事件处理函数
			$(document).on('infinite', function() {
				aja();
			});
			aja();
			//搜索
			$("#findTx").click(function() {
				find = $("#search").val();
				lastIndex = 1;
				$('.infinite-scroll .list-container').html("");
				// 删除加载提示符
				$('.infinite-scroll-preloader').remove();
				$.attachInfiniteScroll($('.infinite-scroll'))
				aja();
			});
			//切换最新页面
			$("#new").click(function() {
				if (site != 1) {
					site = 1;
					find = "";
					lastIndex = 1;
					allPhoto={};
					$('.infinite-scroll .list-container').html("");
					$("#new").attr("class", "tab-link active button");
					$("#hot").attr("class", "button");
					$("#collect").attr("class", "button");
					$.attachInfiniteScroll($('.infinite-scroll'));
					aja();
				}
			});
			//切换最热页面
			$("#hot").click(function() {
				if (site != 2) {
					site = 2;
					find = "";
					lastIndex = 1;
					allPhoto={};
					$('.infinite-scroll .list-container').html("");
					$("#new").attr("class", "button");
					$("#hot").attr("class", "tab-link active button");
					$("#collect").attr("class", "button");
					$.attachInfiniteScroll($('.infinite-scroll'));
					aja();
				}
			});
			//切换多收藏页面
			$("#collect").click(function() {
				if (site != 3) {
					site = 3;
					find = "";
					lastIndex = 1;
					allPhoto={};
					$('.infinite-scroll .list-container').html("");
					$("#new").attr("class", "button");
					$("#hot").attr("class", "button");
					$("#collect").attr("class", "tab-link active button");
					$.attachInfiniteScroll($('.infinite-scroll'));
					aja();
				}
			});
		</script>
		<script>
			$.init();
		</script>
	</body>

</html>
